package is.web.xdumper.client;

import is.xdumper.XdumperConf;
import is.xdumper.XdumperNoPathException;
import java.io.File;
import java.rmi.RemoteException;
import javax.naming.NamingException;

/**
 *
 * @author aspr0
 */
public class XdumperClientConf
{
    //    todo   Files saved relative to home or to domain root. Or absolute Check ??
    public static final String PATH_DUMP_WEB = "/5_isbdx-war/xdumper/out/";

    public static String getPathOutputDir() throws NamingException, RemoteException, XdumperNoPathException
    {
        String pathOutputDir = "5_isbdx/5_isbdx-war_war/xdumper/out/";
        return XdumperConf.getDap() + pathOutputDir;
    }

    public static String getPathOutputDirTmp() throws NamingException, RemoteException, XdumperNoPathException
    {
        String pathOutputDirTmp = "5_isbdx/5_isbdx-war_war/xdumper/out/tmp/";
        String fullPath = XdumperConf.getDap() + pathOutputDirTmp;
        File fullPathFile = new File(fullPath);

        /* Avoiding empty catalog no-deployement */
        if (fullPathFile.exists())
        {
            return fullPath;
        }
        else
        {
            if (fullPathFile.mkdirs())
            {
                return fullPath;
            }
            else
            {
                throw new XdumperNoPathException();
            }
        }
    }
}
